<extend name="layout/main" />

<block name="HEADER">
</block>

<block name="CONTENT">
	<control:grid id="grid"/>
</block>

<block name="FOOTER">
	<script type="text/javascript">
        var page = (function(ns){

            //页面初始化
            ns.init=function(){

            }

            //新增
            ns.add=function(){
                var filter = {
                    url:$.getModule('edit'),
                    oid:"",
                    mode:1
                }
                $.openIframe(filter, "新增",['800px', '92%']);
            }

            //编辑
            ns.edit=function(){

                var selectedRow = grid.getSelectedRows()[0];

                var filter = {
                    url:$.getModule('edit'),
                    // oid: selectedRow.id ,
					oid:selectedRow[grid.option.key],
                    mode:2
                }
                $.openIframe(filter, "运费模板详情",['800px', '92%']);
            }

            //删除
            ns.del =function(){
                var selectedRow = grid.getSelectedRows()[0];
                if(!selectedRow){
                  $.toast(0,'请选择要删除的行！');
                  return false;
				}
                $.ajaxs("/admin/v1/freight/getfreight",{
                    freight_id:selectedRow[grid.option.key]
                }).then(function(){
                    $.toast(1,"删除成功！");
                    grid.deleteSelectRow(true);
                })

            }

            return ns;
        }({}));


        $(function(){ page.init();  });

	</script>
</block>